﻿using System;

using Xamarin.Forms;

namespace Cashbook
{
    public class BillCell : ViewCell
    {
        public BillCell()
        {
            var idLabel = new Label
            {
                HorizontalTextAlignment = TextAlignment.End,
                HorizontalOptions = LayoutOptions.Start,
                FontSize = 20,
                FontAttributes = FontAttributes.Bold,
            };

            idLabel.SetBinding(Label.TextProperty, new Binding("Id"));

			var titleLabel = new Label
			{
				
				HorizontalOptions = LayoutOptions.StartAndExpand,
				FontSize = 20,
				FontAttributes = FontAttributes.Bold,
			};

			titleLabel.SetBinding(Label.TextProperty, new Binding("Title"));

			var amountLabel = new Label
			{
                HorizontalTextAlignment = TextAlignment.End,
				HorizontalOptions = LayoutOptions.StartAndExpand,			
				
			};
			amountLabel.SetBinding(Label.TextProperty, new Binding("Amount"));

            var isPayedSwitch = new Switch
            {
                IsEnabled = false,
                HorizontalOptions = LayoutOptions.End
            };
            isPayedSwitch.SetBinding(Switch.IsToggledProperty,new Binding("IsPayed"));

			var clientLabel = new Label
			{
				HorizontalTextAlignment = TextAlignment.End,
				HorizontalOptions = LayoutOptions.StartAndExpand,

			};
			clientLabel.SetBinding(Label.TextProperty, new Binding("ClientName"));

            var line1 = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children ={
                    idLabel, titleLabel
                }
            };

			var line2 = new StackLayout
			{
				Orientation = StackOrientation.Horizontal,
				Children ={
                    amountLabel, clientLabel, isPayedSwitch,
				}
			};

            View = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Children ={
                    line1,line2,
                }
            };
        }
    }
}

